package yjhsgl.action;

import java.util.HashMap;
import java.util.Map;

import yjhsgl.agent.HsglAgent;
import common.Const;
import common.MyUtils;
import common.BaseClasses.CommonAction;
import common.BaseClasses.util.IocUtil;

public class HsglAction extends CommonAction{

	private HsglAgent hsglAgent;
	private  Map<Object, Object> resultMap;
	
	public HsglAction(){
		try {
			this.hsglAgent=(HsglAgent) IocUtil.getIocImpl("yjhsgl/ioc/ioc-hsgl.xml","hsglAgent");
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	//跳到会商管理页
	public String toHsglPage(){
		Map map=new HashMap();
		resultMap=hsglAgent.selectHsByPage(1, getIntParameter("pageSize"),map);
		setPageParam(resultMap);
		return "toHsglPage";
	}
	
	/**
     * 根据日期查询，或者名称查询会商
     */
    public String searchHs(){
    	Map map=new HashMap();
    	map.put("startTime", getParameter("startTime"));
    	map.put("endTime",getParameter("endTime"));
    	map.put("met_nm", getParameter("met_nm"));
    	//将查询条件存入到分页标签里面
    	paramMap.put("startTime", getParameter("startTime"));
    	paramMap.put("endTime", getParameter("endTime"));
    	paramMap.put("eventName", getParameter("eventName"));
    	resultMap=hsglAgent.selectHsByPage(1, getIntParameter("pageSize"), map);
    	System.out.println("-------------"+resultMap);
        setPageParam(resultMap);
    	return "toHsglFenYePage";
    }
	
	//分页查询会商
	public String findHsByPage(){
    	paramMap.put("mt_nm", getParameter("mt_nm",""));
    	paramMap.put("startTime", getParameter("startTime"));
    	paramMap.put("endTime",getParameter("endTime"));
    	Map map=new HashMap();
    	map.put("mt_nm", getParameter("mt_nm",""));
    	map.put("startTime", getParameter("startTime"));
    	map.put("endTime",getParameter("endTime"));
    	resultMap=hsglAgent.selectHsByPage(pageBean.getCurrentPage(), pageBean.getPageSize(), map);
        setPageParam(resultMap);
    	return "toHsglFenYePage";
	}
	
	public String AddHs(){
		String hsId=getParameter("hsId");
    	Map map=new HashMap();
    	if(hsId!=null&&!(hsId.equals(""))){
    		map.put("id", hsId);
    		map.put("met_nm", getParameter("met_name"));
    		map.put("met_dt", getParameter("met_dt"));
    		map.put("met_place", getParameter("met_place"));
    		map.put("zcdw", getParameter("zcdw"));
    		map.put("met_title", getParameter("met_title"));
    		map.put("gl_eve", getParameter("gl_eve"));
    		map.put("join_unit", getParameter("join_unit"));
    		hsglAgent.updataHs(map);
    		return null;
    	}
    	else{
    		map.put("id", MyUtils.getUUID());
    		map.put("met_nm", getParameter("met_name"));
    		map.put("met_dt", getParameter("met_dt"));
    		map.put("met_place", getParameter("met_place"));
    		map.put("zcdw", getParameter("zcdw"));
    		map.put("met_title", getParameter("met_title"));
    		map.put("gl_eve", getParameter("gl_eve"));
    		map.put("join_unit", getParameter("join_unit"));
    		System.out.println("---------map:"+map);
    		hsglAgent.insert(map);
    		return "success";
    	}
	}
	
	 public void deleteHs(){
	    	String hsIDdArr=getParameter("hsIDdArr");
	    	String result=hsglAgent.deleteHs(hsIDdArr);
	    	writeStringToResponse(result);
	    }
	
	
	public HsglAgent getHsglAgent() {
		return hsglAgent;
	}
	public void setHsglAgent(HsglAgent hsglAgent) {
		this.hsglAgent = hsglAgent;
	}
	public Map<Object, Object> getResultMap() {
		return resultMap;
	}
	public void setResultMap(Map<Object, Object> resultMap) {
		this.resultMap = resultMap;
	}
	
}
